<?php
declare(strict_types=1);

namespace app\validate;

class RoleValidate extends BaseValidate
{
    protected $rule = [
        'role_name' => 'require|length:2,20',
        'role_desc' => 'require|length:2,200',
        'status'    => 'require|in:0,1',
        'menu_ids'  => 'require|array'
    ];

    protected $message = [
        'role_name.require' => '角色名称不能为空',
        'role_name.length'  => '角色名称长度必须在2-20个字符之间',
        'role_desc.require' => '角色描述不能为空',
        'role_desc.length'  => '角色描述长度必须在2-200个字符之间',
        'status.require'    => '状态不能为空',
        'status.in'         => '状态值不正确',
        'menu_ids.require'  => '菜单权限不能为空',
        'menu_ids.array'    => '菜单权限格式不正确'
    ];

    // 添加场景
    public function sceneAdd(): RoleValidate
    {
        return $this->only(['role_name', 'role_desc', 'status', 'menu_ids']);
    }

    // 编辑场景
    public function sceneEdit(): RoleValidate
    {
        return $this->only(['role_name', 'role_desc', 'status', 'menu_ids']);
    }
} 